package org.deng.learn.webflux.config;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Project
 * @Module
 * @JDK_Vserion 1.8
 * @Author DengLibin
 * @Email dlb@smarthse.cn
 * @Desc 异步配置
 * @since 2020/3/12 0012 15:31
 */
@SpringBootConfiguration
@EnableAsync
public class AsyncConfig {

    /**
     * 配置一个自定义的执行异步任务的线程池
     * @return
     */
    @Bean
    @Scope(value = "singleton")
    public ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(5, 10,
                1, TimeUnit.MINUTES, new LinkedBlockingDeque<>(2000));

    }

}
